import 'dart:math';

import 'package:flutter/material.dart';
import 'package:flutter_icons/flutter_icons.dart';
import 'package:flutter_svg/svg.dart';
import 'package:karyo/karyo.dart';

/// A custom Path to paint stars.
Path drawStar(Size size) {
  // Method to convert degree to radians
  double degToRad(double deg) => deg * (pi / 180.0);

  const numberOfPoints = 5;
  final halfWidth = size.width / 2;
  final externalRadius = halfWidth;
  final internalRadius = halfWidth / 2.5;
  final degreesPerStep = degToRad(360 / numberOfPoints);
  final halfDegreesPerStep = degreesPerStep / 2;
  final path = Path();
  final fullAngle = degToRad(360);
  path.moveTo(size.width, halfWidth);

  for (double step = 0; step < fullAngle; step += degreesPerStep) {
    path.lineTo(halfWidth + externalRadius * cos(step),
        halfWidth + externalRadius * sin(step));
    path.lineTo(halfWidth + internalRadius * cos(step + halfDegreesPerStep),
        halfWidth + internalRadius * sin(step + halfDegreesPerStep));
  }
  path.close();
  return path;
}

Widget getGenderIconUser(User contact) {
  double _size = 12.0;
  if (contact.userGender == '0') {
    return new Icon(
      FlutterIcons.male_faw5s,
      color: Colors.blue,
      size: _size,
    );
  } else if (contact.userGender == '1') {
    return new Icon(
      FlutterIcons.female_faw5s,
      color: Colors.pink,
      size: _size,
    );
  } else if (contact.userGender == '2') {
    return new Icon(
      FlutterIcons.android_ant,
      color: Colors.green,
      size: _size,
    );
  } else {
    return new Icon(
      FlutterIcons.female_faw5s,
      color: Colors.blue,
      size: _size,
    );
  }
}

Widget getGenderIcon(Contact contact) {
  double gS = 15;
  if (contact.userGender == '0') {
    return Container(
      width: gS,
      height: gS,
      child: Image.asset("assets/images/ic_man.png"),
    );
  } else if (contact.userGender == '1') {
    return Container(
      width: gS,
      height: gS,
      child: Image.asset("assets/images/ic_woman.png"),
    );
  } else if (contact.userGender == '2') {
    return Container(
      width: gS,
      height: gS,
      child: Image.asset("assets/images/ic_bot.png"),
    );
  } else {
    return Container(
      width: gS,
      height: gS,
      child: Image.asset("assets/images/ic_woman.png"),
    );
  }
}

class MessageInCenterWidget extends StatelessWidget {
  final String _message;

  MessageInCenterWidget(this._message);
  @override
  Widget build(BuildContext context) {
    final _pics = ['assets/images/beach.svg', 'assets/images/beach2.svg'];
    return Center(
      child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
        // Icon(
        //   FlutterIcons.beach_mco,
        //   size: 77,
        //   color: Colors.grey.withAlpha(60),
        // ),
        SvgPicture.asset(
          _pics[Random().nextInt(2)],
          height: 200,
        ),
        SizedBox(
          height: 20,
        ),
        Text(_message,
            style: TextStyle(
                fontSize: FONT_MEDIUM, color: Colors.grey.withAlpha(60)))
      ]),
    );
  }
}
